/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.siseventos.managed;

import br.siseventos.model.TbEvento;
import br.siseventos.service.BaseService;
import br.siseventos.service.EventoService;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

@ManagedBean(name = "inscreverBean")
@ViewScoped
public class InscreverBean extends BaseService {

    private String idEvento;
    private TbEvento evento;
    private EventoService eventoService = new EventoService();

    public InscreverBean() {
    }

    public String getIdEvento() {
        return idEvento;
    }

    public void setIdEvento(String idEvento) {
        this.idEvento = idEvento;
    }

    public TbEvento getEvento() {
        return evento;
    }

    public void setEvento(TbEvento evento) {
        this.evento = evento;
    }
    
    
    @PostConstruct
    public void init() {
        // Buscando o id do evento dos parametros
        idEvento = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("ie");

        // Buscando o evento
        try {
            evento = eventoService.consultar(Integer.parseInt(idEvento));
        } catch (Exception e) {
        }
    }
}
